import 'package:flutter/material.dart';
import '../constants/colors.dart';
import '../constants/text_styles.dart';

/// 设置开关项组件
///
/// 用于显示带开关的设置项
class SettingSwitchItem extends StatelessWidget {
  /// 标题
  final String label;

  /// 副标题（可选）
  final String? subtitle;

  /// 开关值
  final bool value;

  /// 值变化回调
  final ValueChanged<bool> onChanged;

  const SettingSwitchItem({
    super.key,
    required this.label,
    this.subtitle,
    required this.value,
    required this.onChanged,
  });

  @override
  Widget build(BuildContext context) {
    return SwitchListTile(
      title: Text(label, style: AppTextStyles.body1),
      subtitle: subtitle != null
          ? Text(subtitle!, style: AppTextStyles.caption)
          : null,
      value: value,
      onChanged: onChanged,
      activeColor: AppColors.primary,
    );
  }
}
